package com.myway.core.common;

import java.util.HashMap;

public enum SegmentTaxState {
	
	LOCK("LOCK"),UNLOCK("UNLOCK");
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, SegmentTaxState> map;
	

	/**
	 * Construct the hash map at load time
	 */
	static 
	{
		map = new HashMap<String, SegmentTaxState>();
		for (SegmentTaxState type : SegmentTaxState.values()) {
			map.put(type.alias, type);
		}
	}

	SegmentTaxState(String alias) 
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias name
	 *
	 * @param alias
	 *            the alias name of the type
	 *
	 * @return a <code>Action</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static SegmentTaxState valueOfAlias(String alias) 
	{
		SegmentTaxState type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}
	
}
